package com.itheima.health.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVO;
import com.itheima.health.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface UserMapper extends BaseMapper<User> {


    //查询用户信息
    @Select("select ID,BIRTHDAY,GENDER,USERNAME,PASSWORD,REMARK,STATION,TELEPHONE from t_user where USERNAME = #{username}")
    UserVO findUserVoByUserName(@Param("username") String username);

    //查询用户角色
    @Select("select ID,NAME,KEYWORD,DESCRIPTION from t_role tro , t_user_role  tur  where tro.ID = tur.ROLE_ID and tur.USER_ID = #{uid}")
    Set<RoleVO> findRoleByUserId(@Param("uid") Integer id);

    //查询用户权限
    @Select("select ID,NAME,KEYWORD,DESCRIPTION  from t_permission tp , t_role_permission trp  where tp.ID = trp. PERMISSION_ID and trp.ROLE_ID = #{rid}")
    Set<Permission> findPermissionByRoleVoID(@Param("rid") Integer id);
}
